<template>
  <view :style="themeColor">
    <view class="page">
      <view
        class="flex flex-direction flex-wrap align-stretch justify-center benben-position-layout flex inputNewPhone_flex_0"
        :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
        <view class='flex flex-wrap align-stretch justify-between inputNewPhone_fd0_0'>
          <view class='flex flex-wrap align-center inputNewPhone_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
            data-url="1">
            <text class='fu-iconfont2  inputNewPhone_fd0_0_c0_c0'>&#xe794;</text>
          </view>
          <view class='flex flex-wrap align-center'>
            <text class='inputNewPhone_fd0_0_c1_c0'>绑定新手机</text>
          </view>
          <view class='flex align-center justify-end inputNewPhone_fd0_0_c2'>
          </view>
        </view>

      </view>
      <view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
      <!---输入新的手机号-表单flex布局开始-->
      <view class="flex flex-direction flex-wrap align-stretch inputNewPhone_flex_1">
        <view class='flex flex-wrap align-center inputNewPhone_fd1_0'>
          <text class='inputNewPhone_fd1_0_c0'>新手机号码</text>
          <view class='flex flex-wrap align-center inputNewPhone_fd1_0_c1' @click.stop="pickerDiy1704874099380=true">
            <text class='inputNewPhone_fd1_0_c1_c0'>+{{area_code}}</text>
            <image class='inputNewPhone_fd1_0_c1_c1' mode="aspectFit" :src='STATIC_URL+"56.png"'></image>
          </view>
          <benben-input class='flex-sub inputNewPhone_fd1_0_c2' type="number" :focus='true' :placeholder="`请输入新的手机号`"
            confirm-type="done" :maxlength="11" placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx"
            v-model="mobile" />
        </view>
        <view class='flex flex-wrap align-center inputNewPhone_fd1_0'>
          <text class='inputNewPhone_fd1_0_c0'>短信验证</text>
          <benben-input class='flex-sub inputNewPhone_fd1_1_c1' type="number" :placeholder="`请输入验证码`"
            confirm-type="done" :maxlength="4" placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx"
            v-model="code" />
          <benben-send-verification-code key='1687690525918' ref="vCode1687690525918" class=' inputNewPhone_fd1_1_c2'
            :areacode="area_code" after-text='后重新获取' before-text='获取验证码' type='5'
            :phone="mobile"></benben-send-verification-code>
        </view>
        <button class='flex-sub inputNewPhone_fd1_2' @tap.stop="checkCodeFunc()" open-type="contact">完成</button>
      </view>

      <!---输入新的手机号-表单flex布局结束-->


    </view>
    <benben-picker ref="benbenWritePickerCodepicker2" :visible.sync="pickerDiy1704874099380" :value.sync='area_code'
      :options='areaList' mode='selector' :mask-show='true' :timeout='true' :picker-height='88' default-type='area_code'
      :default-props='{"label":"area_name","value":"area_code"}'>
      <template #picker-header>
        <view class='flex flex-wrap align-center justify-between myProfile_picker2_0'>
          <text class='myProfile_picker2_0_c0' @tap="$refs.benbenWritePickerCodepicker2.cancel()">取消</text>
          <text>选择区号</text>
          <text class='myProfile_picker2_0_c2' @tap="$refs.benbenWritePickerCodepicker2.pickerConfirm()">确认</text>
        </view>
      </template>
    </benben-picker>
  </view>
</template>
<script>
  import {
    validate
  } from '@/common/utils/validate.js'

  export default {
    components: {},


    data() {
      return {
        pickerDiy1704874099380: false,
        areaList: [],
        area_code: '',
        "mobile": "",
        "code": ""
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },

    },
    watch: {},
    onLoad(options) {
      this.getArea()
    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {

    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      getArea() {
        this.$api.post(global.apiUrls.post65e6e32934885).then(res => {
          if (res.data.code == 1) {
            this.areaList = res.data.data
            this.area_code = this.areaList[0].area_code
          }
        })
      },
      //校验
      async checkCodeFunc() {
        if (!validate(this.mobile, 'require')) {
          this.$message.info('请输入手机号');
          return false;
        }
        // if (!validate(this.mobile, 'phone')) {
        //   this.$message.info('请输入正确的手机号');
        //   return false;
        // }
        if (!validate(this.code, 'require')) {
          this.$message.info('请输入验证码');
          return false;
        }
        if (!validate(this.code, 'captcha')) {
          this.$message.info('请输入正确的验证码');
          return false;
        }
        //请求方法
        //数据验证

        let data5f6c915d69d1f = await this.$api.post(global.apiUrls.post5f6c915d69d1f, {
          mobile: this.mobile,
          code: this.code,
          type: '5',
          area_code: this.area_code
        });

        if (data5f6c915d69d1f.data.code != 1) {
          this.$message.info(data5f6c915d69d1f.data.msg);
          return
        }



        this.$store.commit('logout')
        setTimeout(() => {
          this.$urouter.reLaunch(`/pages/tabBar/passwordLogin/passwordLogin`);
        }, 500)
      }
    }
  };
</script>
<style lang="scss" scoped>
  .myProfile_picker2_0_c2 {
    color: rgba(100, 80, 235, 1);
  }

  .myProfile_picker2_0_c0 {
    color: var(--benbenFontColor2);
  }

  .myProfile_picker2_0 {
    border-bottom: 1px solid #eee;
    background: #fff;
    padding: 0rpx 32rpx 0rpx 32rpx;
    line-height: 88rpx;
    border-radius: 25rpx 25rpx 0rpx 0rpx;
    background-size: 100% auto !important;
  }

  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: rgba(255, 255, 255, 1);
    background-size: 100% auto;
  }

  .inputNewPhone_flex_0 {
    border-bottom: 1px solid #eee;
    background: #fff;
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto !important;
  }

  .inputNewPhone_fd0_0_c2 {
    padding: 0rpx 0rpx 0rpx 0rpx;
    width: 100rpx;
  }

  .inputNewPhone_fd0_0_c1_c0 {
    font-size: 36rpx;
    font-weight: 500;
    color: var(--benbenFontColor0);
    line-height: 50rpx;
  }

  .inputNewPhone_fd0_0_c0_c0 {
    font-size: 36rpx;
    font-weight: 400;
    color: #333;
  }

  .inputNewPhone_fd0_0_c0 {
    width: 100rpx;
  }

  .inputNewPhone_fd0_0 {
    padding: 0rpx 32rpx 0rpx 32rpx;
    line-height: 88rpx;
  }

  .inputNewPhone_flex_1 {
    background: #fff;
    font-size: 32rpx;
    background-size: 100% auto !important;
    padding: 0rpx 32rpx 0rpx 32rpx;
  }

  .inputNewPhone_fd1_2 {
    background: rgba(100, 80, 235, 1);
    border-radius: 44rpx 44rpx 44rpx 44rpx;
    font-size: 32rpx;
    color: #fff;
    margin: 297rpx 32rpx 0rpx 32rpx;
    height: 88rpx;
    line-height: 88rpx;
    width: 638rpx;
  }

  .inputNewPhone_fd1_1_c2 {
    font-size: 28rpx;
    font-weight: 400;
    color: rgba(100, 80, 235, 1);
  }

  .inputNewPhone_fd1_1_c1 {
    line-height: 45rpx;
    color: var(--benbenFontColor0);
    font-size: 32rpx;
    font-weight: 400;
  }

  .inputNewPhone_fd1_0_c2 {
    line-height: 45rpx;
    font-size: 28rpx;
    font-weight: 400;
    color: var(--benbenFontColor0);
  }

  .inputNewPhone_fd1_0_c1_c1 {
    width: 14rpx;
    height: 8rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }

  .inputNewPhone_fd1_0_c1_c0 {
    color: #333333;
    font-size: 32rpx;
    font-weight: 400;
    line-height: 34rpx;
    margin: 0rpx 8rpx 0rpx 0rpx;
  }

  .inputNewPhone_fd1_0_c1 {
    margin: 0rpx 9rpx 0rpx 0rpx;
  }

  .inputNewPhone_fd1_0_c0 {
    font-size: 32rpx;
    font-weight: 400;
    font-style: normal;
    color: rgba(127, 127, 127, 1);
    width: 182rpx;
  }

  .inputNewPhone_fd1_0 {
    border-bottom: 1px solid #eee;
    padding: 32rpx 0rpx 32rpx 0rpx;
  }
</style>
